
#include "../include/qtwi/core/iifactory.hpp"
#include "../include/qtwi/core/iiapplication.hpp"

// Ifactory

IWindow* TIfactory::mainWindow(const char *title, int x, int y)
{

	TIApplication *tiapp = dynamic_cast<TIApplication*>(app);
		
	// todo: color?
	tiapp->MainConstructor(title, tiapp->getArgc(), tiapp->getArgv(),
			       MWRGB(255, 255, 255), 0, 0, x, y, NULL);

	std::cout << "here color: " << MWRGB(100, 100, 255) << std::endl;
		
	TIWindow *w = new TIWindow(tiapp->GetMainWidget(), title);

	tnSetWidgetBGColor(tiapp->GetMainWidget(), MWRGB(255,255,255));
		
	app->registerAction(*w, IAction::CLOSE, &ticah);
		
	return w;
}

IWindow* TIfactory::makeWindow(const char *title, int x, int y)
{
	if(!app) throw IFactoryAppNotSet();
	TIWindow *w = new TIWindow(dynamic_cast<TIApplication*>(app)->GetAppWidget(),
				   title, x, y);
	app->registerAction(*w, IAction::CLOSE, &twcah);
	return w;
}
	
